package org.dtrd.modules.record.service;

import org.dtrd.config.system.Constant;
import org.dtrd.modules.device.entity.bean.bioland.SrcDataValue;
import org.dtrd.modules.record.entity.bean.BloodBean;
import org.dtrd.modules.record.entity.bean.BloodPressureChartBean;
import org.dtrd.modules.record.entity.bean.BloodPressureDailyInfo;
import org.dtrd.modules.record.entity.bean.PeriodBloodPressure;
import org.dtrd.modules.record.entity.po.DtrdEntRdSigninBloodPressure;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author 萧
 * @date:2021-08-23
 **/
public interface IBloodPressureRecordService extends IRecordService<DtrdEntRdSigninBloodPressure> {

    void saveBiolandRecord(SrcDataValue srcDatavalue, Integer userId);

    PeriodBloodPressure getBloodPressureRecordsForCharts(Integer patientId, String startDate, String endDate);

    List<BloodBean> getAllBloodPressureByPage(int patientId, int page, int pageSize);

    List<BloodBean> getAllBloodPressureByDate(int patientId, String startDate, String endDate, boolean isAsc);

    BloodPressureChartBean getBloodPressureRecordsForChartsInApp(int patientId, String startDate, String endDate);

    List<BloodBean> getAllBloodPressureBetweenTimeByPage(int patientId, String startDate, String endDate, int page, int pageSize);

    Integer getBloodPressureRecordDateCount(int patientId, String startDate, String endDate);

    Map getBloodPressureStatistics(int patientId, int type, String startTime, String endTime, int period);

    /**
     * 新增血压记录
     */
    boolean saveBloodPressureRecord(BloodPressureDailyInfo info);

    /**
     * 获取对应 patientId 的对应 date 的血压记录
     *
     * @param patientId 患者Id
     * @param date      查询日期
     * @return 查询的当日血压记录
     */
    BloodPressureDailyInfo getBloodPressure(Integer patientId, Date date);

    /**
     * 计算血压高压平均值
     *
     * @param patientId
     * @param startOfWeek
     * @param endOfWeek
     * @return
     */
    Integer getAvgBloodHighPressure(Integer patientId, String startOfWeek, String endOfWeek);

    /**
     * 计算血压低压平均值
     *
     * @param patientId
     * @param startOfWeek
     * @param endOfWeek
     * @return
     */
    Integer getAvgBloodLowPressure(Integer patientId, String startOfWeek, String endOfWeek);

    /**
     * 添加血压记录, 根据类型添加
     */
    boolean saveBloodPressureRecord(BloodBean bloodInfo);

    /**
     * 计算心率平均值
     *
     * @param patientId
     * @param startOfWeek
     * @param endOfWeek
     * @return
     */
    Integer getAvgBloodHeartrate(Integer patientId, String startOfWeek, String endOfWeek);

    /**
     * 通过 patientId 获取最新的血压记录
     */
    DtrdEntRdSigninBloodPressure getBloodPressureRecordLatestByPatientId(Integer patientId);

    /**
     * 获取指定类型的最初的一条舒张压，收缩压，心率打卡记录的数值
     * @param patientId
     * @param bloodPressure
     * @return
     */
    Float getFirstBloodPressureValue(Integer patientId, Constant.BloodPressure bloodPressure);
}
